package com.sjp.service.impl;

import com.sjp.dao.BlogCategoryMapper;
import com.sjp.pojo.BlogCategory;
import com.sjp.service.CategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Service
public class CategoryServiceImpl implements CategoryService {

    @Autowired
    private BlogCategoryMapper blogCategoryMapper;

    @Override
    public List<BlogCategory> queryAllCategory() {
        this.setCount();
        return blogCategoryMapper.queryAllCategory();
    }

    @Override
    public boolean saveCategory(String name) {
        return blogCategoryMapper.saveCategory(name);
    }

    @Override
    public int deleteCategory(@RequestBody Integer[] ids) {
        return blogCategoryMapper.deleteCategory(ids);
    }

    @Override
    public boolean updateCategory(Integer id, String name) {
        return blogCategoryMapper.updateCategory(id,name);
    }

    @Override
    public int countCategory() {
        return blogCategoryMapper.countCategory();
    }

    @Override
    public boolean setCount() {
        return blogCategoryMapper.setCount();
    }

    @Override
    public String queryNameById(Integer id) {
        return blogCategoryMapper.queryNameById(id);
    }
}
